import java.util.Arrays;
import java.util.Comparator;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 18128
 * Date: 2023-09-23
 * Time: 20:55
 */
class ren
{
    public int age;
    public String name;
    public ren()
    {

    }
    public ren(int age,String name)
    {
        this.age=age;
        this.name=name;
    }

    @Override
    public String toString() {
        return "姓名"+name+" "+"年龄"+age;
    }
}
class namebj implements Comparator<ren>
{
    @Override
    public int compare(ren o1, ren o2) {
        return o1.name.compareTo(o2.name);
    }
}
public class sos {
    public static void paixu(ren[] rrr,namebj nj)
    {
        for (int i = 0; i < rrr.length-1; i++) {
            for (int j = 0; j < rrr.length-i-1; j++) {
                if(nj.compare(rrr[j],rrr[j+1])>0)
                {
                    ren t=rrr[j];
                    rrr[j]=rrr[j+1];
                    rrr[j+1]=t;
                }
            }
        }
    }
    public static void main(String[] args) {
        ren rrr[]=new ren[3];
        rrr[0]=new ren(10,"hjx");
        rrr[1]=new ren(16,"ijx");
        rrr[2]=new ren(13,"ajx");
        namebj nj=new namebj();
        paixu(rrr,nj);
        System.out.println(Arrays.toString(rrr));
    }
}
